<?php

namespace App\Http\Controllers\Home;

use App\Http\Controllers\Controller;
use App\Model\ConfigModel;
use Illuminate\Http\Request;

class ProjectController extends Controller
{
    public function index()
    {
        $data['cases'] = \DB::table('cases')
            ->orderBy('created_at','desc')
            ->select(['id','img','case_title','abstract'])
            ->get();
        $data['seo'] = ConfigModel::where('config_type','cases')
            ->first();
        return view('front.project')->with('data',$data);
    }

    public function detail($id)
    {
        $data['info'] = \DB::table('cases')
            ->find($id);
        if (empty($data['info'])){
            abort(404);
        }
        $data['cases'] = \DB::table('cases')
            ->orderBy('created_at','desc')
            ->take(6)
            ->select(['id','case_title'])
            ->get();
        return view('front.project-detail')->with('data',$data);
    }
}
